﻿package mortal.game.resource.tableConfig
{
    import Message.Client.*;
    import Message.DB.Tables.*;
    import Message.Public.*;
    import __AS3__.vec.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.view.common.*;

    public class MountConfig extends Object
    {
        private var _mountMap:Dictionary;
        private var _mountColorMap:Dictionary;
        private var _mountLotteryMap:Dictionary;
        private var _mountTargetMap:Dictionary;
        private var _vcAttribute:Vector.<String>;
        private var _attribute:Vector.<String>;
        private var _fashionMap:Dictionary;
        private var _mountBlessStoneDic:Dictionary;
        private static var _instance:MountConfig;

        public function MountConfig()
        {
            this._mountMap = new Dictionary();
            this._mountColorMap = new Dictionary();
            this._mountLotteryMap = new Dictionary();
            this._mountTargetMap = new Dictionary();
            this._vcAttribute = new Vector.<String>;
            this._attribute = new Vector.<String>;
            this._fashionMap = new Dictionary();
            this._mountBlessStoneDic = new Dictionary();
            if (_instance != null)
            {
                throw new Error(" MountConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        private function init() : void
        {
            this._vcAttribute.push("addPenetration", "addCrit", "addToughness", "addHit", "addJouk", "addExpertise", "addBlock");
            this._attribute.push("attack", "life", "physDefense", "magicDefense", "penetration", "jouk", "hit", "crit", "toughness", "block", "expertise");
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_mount_config.json");
            this.write(_loc_1);
            _loc_1 = ConfigManager.instance.getJSONByFileName("t_mount_bless_stone_config.json");
            this.writeBlessSton(_loc_1);
            return;
        }// end function

        private function writeBlessSton(param1:Object) : void
        {
            var _loc_2:TMountBlessStoneConfig = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TMountBlessStoneConfig();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._mountBlessStoneDic[_loc_2.level] = _loc_2;
            }
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TMountConfig = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TMountConfig();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                if (_loc_2.type == 0)
                {
                    this._mountMap[_loc_2.code] = _loc_2;
                }
                if (_loc_2.type == EAdvanceComponentType._EAdvanceComponentTypeClothes || _loc_2.type == EAdvanceComponentType._EAdvanceComponentTypeWing || _loc_2.type == EAdvanceComponentType._EAdvanceComponentTypeWeapon || _loc_2.type == EMountConfigType._EMountConfigPetGrow || _loc_2.type == EAdvanceComponentType._EAdvanceComponentTypeFightSoul || _loc_2.type == EAdvanceComponentType._EAdvanceComponentTypeFightMethod || _loc_2.type == EAdvanceComponentType._EAdvanceComponentTypeDragonSoul || _loc_2.type == EAdvanceComponentType._EAdvanceComponentTypeHolyBook || _loc_2.type == EAdvanceComponentType._EAdvanceComponentTypeWarShield || _loc_2.type == EAdvanceComponentType._EAdvanceComponentTypeMonsterSoul || _loc_2.type == EAdvanceComponentType._EAdvanceComponentTypePet)
                {
                    this._fashionMap[_loc_2.type + "-" + _loc_2.code] = _loc_2;
                }
            }
            return;
        }// end function

        private function writeColor(param1:Object) : void
        {
            var _loc_2:TMountCardColorConfig = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TMountCardColorConfig();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._mountColorMap[_loc_2.colorType] = _loc_2;
            }
            return;
        }// end function

        private function writeLottery(param1:Object) : void
        {
            var _loc_2:TMountCardLotteryConfig = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TMountCardLotteryConfig();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._mountLotteryMap[_loc_2.times] = _loc_2;
            }
            return;
        }// end function

        private function writeTarget(param1:Object) : void
        {
            var _loc_2:TMountCardTarget = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TMountCardTarget();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._mountTargetMap[_loc_2.cardId + "_" + _loc_2.cardLevel] = _loc_2;
            }
            return;
        }// end function

        public function getMountInfoByCode(param1:int, param2:int = 0) : TMountConfig
        {
            if (param2 == 0)
            {
                return this._mountMap[param1];
            }
            return this._fashionMap[param2 + "-" + param1];
        }// end function

        public function get mountMap() : Dictionary
        {
            return this._mountMap;
        }// end function

        public function getMountColorConfigByColor(param1:int) : TMountCardColorConfig
        {
            return this._mountColorMap[param1];
        }// end function

        public function getMountLotteryConfigByTimes(param1:int) : TMountCardLotteryConfig
        {
            return this._mountLotteryMap[param1];
        }// end function

        public function getMountTargetByIdAndLevel(param1:String) : TMountCardTarget
        {
            return this._mountTargetMap[param1];
        }// end function

        public function get attribute() : Vector.<String>
        {
            return this._attribute;
        }// end function

        public function getFashionInfoByCode(param1:int, param2:int) : TMountConfig
        {
            return this._fashionMap[param1 + "-" + param2];
        }// end function

        public function get mountConfigArr() : Array
        {
            var _loc_2:TMountConfig = null;
            var _loc_1:Array = [];
            for each (_loc_2 in this._mountMap)
            {
                
                _loc_1.push(_loc_2);
            }
            return _loc_1;
        }// end function

        public function getFashionsByType(param1:int) : Array
        {
            var _loc_3:TMountConfig = null;
            var _loc_2:Array = [];
            if (param1 == EAdvanceComponentType._EAdvanceComponentTypeMount)
            {
                _loc_2 = this.mountConfigArr;
            }
            else
            {
                for each (_loc_3 in this._fashionMap)
                {
                    
                    if (_loc_3.type == param1)
                    {
                        _loc_2.push(_loc_3);
                    }
                }
            }
            return _loc_2;
        }// end function

        public function getMuntBlessStoneDic(param1:int) : TMountBlessStoneConfig
        {
            return this._mountBlessStoneDic[param1];
        }// end function

        public static function get instance() : MountConfig
        {
            if (_instance == null)
            {
                _instance = new MountConfig;
            }
            return _instance;
        }// end function

    }
}
